#ifndef DSPSIMULATOR_TARGETMACHINE_H
#define DSPSIMULATOR_TARGETMACHINE_H

#include <memory>
#include <utility>
#include "simulator/targetMachine/registerMap.h"
#include "simulator/targetMachine/memoryManageUnit.h"
#include "simulator/instFetcher.h"

namespace simulator {
    class TargetMachine {
    protected:
        std::shared_ptr<InstructionFetcher> m_instruction_fetcher;
        std::shared_ptr<MMU> m_mmu;
        std::shared_ptr<RegisterMap> m_regs;
    public:
        TargetMachine() : m_instruction_fetcher(nullptr),
                          m_mmu(std::make_shared<MMU>()),
                          m_regs(std::make_shared<RegisterMap>()) {};

        TargetMachine(const TargetMachine &) = delete;

        TargetMachine &operator=(const TargetMachine &) = delete;

        virtual ~TargetMachine() = default;

        std::shared_ptr<MMU> mmu() const { return m_mmu; };

        std::shared_ptr<RegisterMap> registers() const { return m_regs; };

        std::shared_ptr<InstructionFetcher> instruction_fetcher() const { return m_instruction_fetcher; }

        void set_mmu(std::shared_ptr<MMU> mmu) { m_mmu = std::move(mmu); }

        void set_reg_map(std::shared_ptr<RegisterMap> reg_map) { m_regs = std::move(reg_map); }

        void set_instruction_fetcher(std::shared_ptr<InstructionFetcher> instruction_fetcher) {
            m_instruction_fetcher = std::move(instruction_fetcher);
        }
    };
}
#endif //DSPSIMULATOR_TARGETMACHINE_H
